import request from '@/utils/request';

export interface OssConfig {
  id: string;
  tenantId?: string;
  name: string;
  type: 'minio' | 'oss' | 's3' | 'local';
  endpoint: string;
  port: number;
  useSsl: boolean;
  accessKey: string;
  secretKey: string;
  bucketName: string;
  region?: string;
  isDefault: boolean;
  isActive: boolean;
  maxFileSize: number;
  allowedTypes?: string;
  remark?: string;
  createdAt: string;
  updatedAt: string;
}

export interface OssConfigQuery {
  page?: number;
  pageSize?: number;
  name?: string;
  type?: string;
}

// 获取OSS配置列表
export const getOssConfigs = (params: OssConfigQuery) => {
  return request.get('/oss-configs', { params });
};

// 获取默认配置
export const getDefaultOssConfig = () => {
  return request.get('/oss-configs/default');
};

// 获取单个配置
export const getOssConfig = (id: string) => {
  return request.get(`/oss-configs/${id}`);
};

// 创建配置
export const createOssConfig = (data: Partial<OssConfig>) => {
  return request.post('/oss-configs', data);
};

// 更新配置
export const updateOssConfig = (id: string, data: Partial<OssConfig>) => {
  return request.put(`/oss-configs/${id}`, data);
};

// 删除配置
export const deleteOssConfig = (id: string) => {
  return request.delete(`/oss-configs/${id}`);
};
